<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Order extends Model
{   
    protected $table = 'orders';
    //
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'user_id',
        'option_id',
        'orderno',
        'symbol',
        'amount',
        'pays',
        'rate',
        'profit',
        'buy_point',
        'close_point',
        'direction',
        'times',
        'close_time',
        'status'
    ];

    public function status(){
        $status = ['未结算','已结算','已作废'];
        return $status[$this->status];
    }

    public function statuslabel(){
        $status = ['label-primary ','label-success','label-danger'];
        return $status[$this->status];
    }

    public function user(){
        return $this->belongsTo('App\User');
    }

    public function option(){
        return $this->belongsTo('App\Models\Option');
    }

    public function directioninfo(){
        $status = ['<span class="label label-success label-mini"><i class="icon-arrow-down"></i></span>','<span class="label label-danger label-mini"><i class="icon-arrow-up"></i></span>'];
        return $status[$this->direction];
    }

}
